package cn.edu.scau.cmi.linyiqu.adapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.edu.scau.cmi.linyiqu.adapter.Student;
import cn.edu.scau.cmi.linyiqu.adapter.SortUtil;

public class AdapterOfClass extends SortUtil implements Adaptee {
	@Override
	public void sortStudent(List<Student> studentList) {
		Map<Integer, String> map = new HashMap<>(); // k means ID, v means Name
		List<Integer> integerList = new ArrayList<>();
		for (Student student : studentList) {
			map.put(student.getId(), student.getName());
			integerList.add(student.getId());
		}
		sortInt(integerList);
		studentList.clear();
		for (Integer integer : integerList) {
			studentList.add(new Student(integer, map.get(integer)));
		}
	}
}
